/**
 * Copyright (C), 2001-2031, www.bosssof.com.cn
 * FileName: MemberHandler.java
 * Author: shixianwei
 * Date: 2024/8/12 11:19
 * Description:
 * <p>
 * History:
 * Date          Author   Version  Desc
 * 2024-01-01    bosssoft  1.0.0   initialize this file
 */
package com.bosssoft.setp.handler;

import com.bosssoft.setp.model.business.power.AllianceMember;
import org.springframework.stereotype.Service;
import xyz.erupt.annotation.fun.DataProxy;
import xyz.erupt.core.exception.EruptApiErrorTip;
import xyz.erupt.jpa.dao.EruptDao;

import javax.annotation.Resource;

/**
 * @className: MemberHandler
 * @description:
 * 对加盟商人员管理的处理类
 * @author: shixianwei
 * @date: 2024/8/12 11:19
 * @since 1.0
 **/
@Service
public class MemberHandler implements DataProxy<AllianceMember> {


    @Resource
    private EruptDao eruptDao;


    @Override
    public void beforeAdd(AllianceMember member) {
        //数据校验
        String sql = "SELECT COUNT(*) FROM setp_privilege_alliance_business_member WHERE setp_mumber_link_alliance = ?";
        Long count = eruptDao.getJdbcTemplate().queryForObject(
                sql, Long.class, member.getBasicBusinessAllianceBusiness().getId());
        if (count > 0) {
            throw new EruptApiErrorTip("添加失败！已有该加盟商的人员管理。");
        }
    }


}

